package com.lanyou.cook.entity.domain;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.beanutils.PropertyUtils;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name = "T_COOK_DB_LOOKUP_VALUE")
public class DataDictionaryValue {
	
	public static final int MAX_LENGTH_OF_CODE = 50;
	
	@EmbeddedId
	@JsonIgnore
	private DataDictionaryValueKey id;
	
	@Column(name="LOOKUP_VALUE_NAME", length=100)
	private String valueName;
	
	@Column(name="ORDER_NO")
	private int order;
	
	
	public DataDictionaryValueKey getId() {
		return id;
	}

	public void setId(DataDictionaryValueKey id) {
		this.id = id;
	}

	@Transient
	public String getTypeCode() {
		try {
			return (String) PropertyUtils.getProperty(id, "typeCode");
		} catch (Exception e) {
			return null;
		}
	}

	@Transient
	public String getValueCode() {
		try {
			return (String) PropertyUtils.getProperty(id, "valueCode");
		} catch (Exception e) {
			return null;
		}
	}

	public String getValueName() {
		return valueName;
	}

	public void setValueName(String valueName) {
		this.valueName = valueName;
	}

	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

}
